<?php
class Fender_ErrorHandler extends Fender_Base_Behavior
{
	protected $logger;

	public function execute(Fender_Logger $logger)
	{
		$this->logger = $logger;
		set_error_handler(array($this, 'errorHander'));
		set_exception_handler(array($this, 'exceptionHandler'));
	}

	public function errorHander($no, $message, $file, $line)
	{
		$exception = new exception($message);
		$this->exceptionHandler($exception);
	}

	public function exceptionHandler(exception $exception)
	{
		$this->logger->write($exception->getMessage());
	}
}
